/**
 * @author mapeng
 * @version 2017-05-10
 */

(function(doc, win) {

	var pageVariables = {
		"shopId" : "" , 
		"weixinAccount" : {} 
	};

	$(doc).on("pageInit", "#weixinChangePage4Wangshang", function(e, pageId, $page, isBack , isForward) {
		if(isForward || isBack) return;

		initData4Page();
	});
	bindEvent4Page();

	//页面初始化
	function initData4Page(){

		//页面参数
		var params = CommonUtil.takeOutParamObject() || {};
		pageVariables.shopId = params.shopId;	

		//查询微信账户
        CommonUtil.sendJsonpRequest({
        // apiTest.testGetAccount({
        	"url" : App.serverUrl + "/app/wxAccountCloudBox/getShopAccountDetail.do",
        	"params" : {"shopId" : pageVariables.shopId},
        	"success" : function(result){
        		if(result.success.toString() == "true"){//success

        			pageVariables.weixinAccount = result.resultObject;
        			CommonUtil.render($("#weixinChangePage4Wangshang .page-body"), "weixinChangeTPL4Wangshang",{"data":pageVariables.weixinAccount},false);

        			//账户类型
        			init4AccountType();

					//开户行地区
					init4BankDistrict();

					//开户主银行
					// init4AccountMainBank();

        		}else{//business error
        			DialogUtil.dialogWarn(result.msg);
        		}
        	},
        	"error" : function(){//not 200
        		DialogUtil.dialogWarn("请求失败，请稍候重试");
        	}
        });

	}

	//账户类型
	function init4AccountType(){

        $("#weixinChangePage4Wangshang div[name='accountType'] input[type='text']").val(Constants.weixin_wangshang.getAccountTypeText(pageVariables.weixinAccount.accountType));
        $("#weixinChangePage4Wangshang div[name='accountType'] input[type='hidden']").val(pageVariables.weixinAccount.accountType);
        setFields4AccountType(pageVariables.weixinAccount.accountType);
	}

	//可见字段：账户类型
	function setFields4AccountType(accountType){
    	if(accountType == Constants.weixin_wangshang.ACCOUNT_TYPE.person){//对私账户
    		// $("#weixinChangePage4Wangshang input[name='contactLine']").parents("li").css("display","none");	//联行号
    		$("#weixinChangePage4Wangshang input[name='accounterCard']").parents("li").css("display","");	//开户人身份证号
    		$("#weixinChangePage4Wangshang input[name='accounterAddress']").parents("li").css("display","");	//开户人地址
    	}else if(accountType == Constants.weixin_wangshang.ACCOUNT_TYPE.company){//对公账户
    		// $("#weixinChangePage4Wangshang input[name='contactLine']").parents("li").css("display","");
    		$("#weixinChangePage4Wangshang input[name='accounterCard']").parents("li").css("display","none");
    		$("#weixinChangePage4Wangshang input[name='accounterAddress']").parents("li").css("display","none");
    	}
	}


	//开户行地区
	function init4BankDistrict(){

		CityUtil.getProvinceCityHtml(function(ul){
			//初始化插件
	    	$("#weixinChangePage4Wangshang div[name='bankDistrict']").prepend(ul);
	    	$("#weixinChangePage4Wangshang div[name='bankDistrict']>ul").mobiscroll().treelist({
	            "theme": "ios",
	            "display": "bottom",
	            "lang": "zh",
	            "placeholder": "请选择省、市",
	            "formatValue" : function(data){
	            	return data.join("-");
	            },
	            "onSelect" : function(valueText,inst){
	            	var codeArray = [];
	            	var $ul = $this = $(this);
	            	$.each(valueText.split("-"),function(index,value){
	            		var $li = $ul.children("li[data-val='"+value+"']");
	            		codeArray.push($li.attr("data-code"));  //data会进行类型转换
	            		$ul = $li.children("ul").eq(0);
	            	});
	            	$this.parent().find("input[type='hidden']").val(codeArray.join(","));
					init4AccountMainBank("district");//选中以后联动
	            	listen4Submit();
	        	}
	    	});

	    	//设定值
	    	$("#weixinChangePage4Wangshang div[name='bankDistrict']>ul").mobiscroll("setArrayVal",[pageVariables.weixinAccount.branchProvinceName,pageVariables.weixinAccount.branchCityName],true);
			$("#weixinChangePage4Wangshang div[name='bankDistrict']>input[type='hidden']").val(pageVariables.weixinAccount.branchProvince+","+pageVariables.weixinAccount.branchCity);
			init4AccountMainBank();//初始化后联动
	    });

        
	}

	//开户主银行
	function init4AccountMainBank(district){
		//销毁组件
		if($("#weixinChangePage4Wangshang div[name='mainBank']>ul").length > 0){
			$("#weixinChangePage4Wangshang div[name='mainBank']>ul").mobiscroll("destroy");
			$("#weixinChangePage4Wangshang div[name='mainBank']>ul").remove();
			$("#weixinChangePage4Wangshang div[name='mainBank']>input[type='hidden']").val("");
		}
		if($("#weixinChangePage4Wangshang div[name='branchBank']>ul").length > 0){
			$("#weixinChangePage4Wangshang div[name='branchBank']>ul").mobiscroll("destroy");
			$("#weixinChangePage4Wangshang div[name='branchBank']>ul").remove();
			$("#weixinChangePage4Wangshang div[name='branchBank']>input[type='hidden']").val("");
			$("#weixinChangePage4Wangshang input[name='contactLine']").val("");	//联行号
		}
		var bankDistrict = $("#weixinChangePage4Wangshang div[name='bankDistrict'] input[type='hidden']").val();//开户行地区
        CommonUtil.sendJsonpRequest({
        // apiTest.testGetBankList({
        	"url" : App.serverUrl + "/app/wxAccountCloudBox/getBanks.do",
        	"params" : {bankDistrict:bankDistrict},
        	"success" : function(result){
        		if(result.success.toString() == "true"){//success

        			//初始化组件
        			var bankList = result.resultObject;
        			var bankListHtml = "<ul style='display:none;'>";
        			$.each(bankList,function(index,element){
        				bankListHtml += "<li data-code='"+element.bankCode+"' data-val='"+element.bankName+"'>"+element.bankName+"</li>";
        			});
        			bankListHtml += "</ul>";
        			$("#weixinChangePage4Wangshang div[name='mainBank']").prepend(bankListHtml);

					$("#weixinChangePage4Wangshang div[name='mainBank']>ul").mobiscroll().treelist({
			            "theme": "ios",
			            "display": "bottom",
			            "lang": "zh",
			            "placeholder": "请选择",
			            "onSelect" : function(valueText,inst){
			            	var codeArray = [];
			            	var $ul = $this = $(this);
			            	$.each(valueText.split("-"),function(index,value){
			            		var $li = $ul.children("li[data-val='"+value+"']");
			            		codeArray.push($li.attr("data-code"));  //data会进行类型转换
			            		$ul = $li.children("ul").eq(0);
			            	});
			            	$this.parent().find("input[type='hidden']").val(codeArray.join(","));
							init4AccountBranchBank("mainBank");
			            	listen4Submit();
			            }
			        });
					if(!district){
						//设置值
						if(pageVariables.weixinAccount.bankId){
							$("#weixinChangePage4Wangshang div[name='mainBank']>ul").mobiscroll("setVal",pageVariables.weixinAccount.bankCode,true);
							$("#weixinChangePage4Wangshang div[name='mainBank']>input[type='hidden']").val(pageVariables.weixinAccount.bankId);
						}
						init4AccountBranchBank();
					}

        		}else{//business error
        			DialogUtil.dialogWarn(result.msg);
        		}
        	},
        	"error" : function(){//not 200
        		DialogUtil.dialogWarn("请求失败，请稍候重试");
        	}
        });
	}

	//开户支行
	function init4AccountBranchBank(mainBankCode){
		//销毁组件
		if($("#weixinChangePage4Wangshang div[name='branchBank']>ul").length > 0){
			$("#weixinChangePage4Wangshang div[name='branchBank']>ul").mobiscroll("destroy");
			$("#weixinChangePage4Wangshang div[name='branchBank']>ul").remove();
			$("#weixinChangePage4Wangshang div[name='branchBank']>input[type='hidden']").val("");
			$("#weixinChangePage4Wangshang input[name='contactLine']").val("");	//联行号
		}
		var bankDistrict = $("#weixinChangePage4Wangshang div[name='bankDistrict'] input[type='hidden']").val();//开户行地区
		var bankId  = $("#weixinChangePage4Wangshang div[name='mainBank']>input[type='hidden']").val();//开户银行Id
		if(bankId){
			CommonUtil.sendJsonpRequest({
			// apiTest.testGetBankList({
				"url" : App.serverUrl + "/app/wxAccountCloudBox/queryMerchantBankBranchAnt.do",
				"params" : {bankDistrict:bankDistrict,bank:bankId},
				"success" : function(result){
					if(result.success.toString() == "true"){//success
	
						//初始化组件
						var bankList = result.resultObject;
						var bankListHtml = "<ul style='display:none;'>";
						$.each(bankList,function(index,element){
							bankListHtml += "<li data-code='"+element.contactLine+"' data-val='"+element.bankName+"'>"+element.bankName+"</li>";
						});
						bankListHtml += "</ul>";
						$("#weixinChangePage4Wangshang div[name='branchBank']").prepend(bankListHtml);
	
						$("#weixinChangePage4Wangshang div[name='branchBank']>ul").mobiscroll().treelist({
							"theme": "ios",
							"display": "bottom",
							"lang": "zh",
							"placeholder": "请选择",
							"onSelect" : function(valueText,inst){
								var codeArray = [];
								var $ul = $this = $(this);
								$.each(valueText.split("-"),function(index,value){
									var $li = $ul.children("li[data-val='"+value+"']");
									codeArray.push($li.attr("data-code"));  //data会进行类型转换
									// $ul = $li.children("ul").eq(0);
									$("#weixinChangePage4Wangshang input[name='contactLine']").val($li.attr("data-code"));	//联行号
								});
								$this.parent().find("input[type='hidden']").val(valueText);
								listen4Submit();
							}
						});
						if(!mainBankCode){
							//设置值
							   $("#weixinChangePage4Wangshang div[name='branchBank']>ul").mobiscroll("setVal",pageVariables.weixinAccount.branchName,true);
							   $("#weixinChangePage4Wangshang div[name='branchBank']>input[type='hidden']").val(pageVariables.weixinAccount.branchName);
							   $("#weixinChangePage4Wangshang input[name='contactLine']").val(pageVariables.weixinAccount.contactLine);	//联行号
						}
	
					}else{//business error
						DialogUtil.dialogWarn(result.msg);
					}
				},
				"error" : function(){//not 200
					DialogUtil.dialogWarn("请求失败，请稍候重试");
				}
			});
		}else{
			//初始化空组件
									//初始化组件
			var bankList = [{"contactLine":"","bankName":""}];
			var bankListHtml = "<ul style='display:none;'>";
			$.each(bankList,function(index,element){
				bankListHtml += "<li data-code='"+element.contactLine+"' data-val='"+element.bankName+"'>"+element.bankName+"</li>";
			});
			bankListHtml += "</ul>";
			$("#weixinChangePage4Wangshang div[name='branchBank']").prepend(bankListHtml);
			$("#weixinChangePage4Wangshang div[name='branchBank']>ul").mobiscroll().treelist({
				"theme": "ios",
				"display": "bottom",
				"lang": "zh",
				"placeholder": "请选择",
				"disabled":"true"
				// "onSelect" : function(valueText,inst){
				// 	var codeArray = [];
				// 	var $ul = $this = $(this);
				// 	$.each(valueText.split("-"),function(index,value){
				// 		var $li = $ul.children("li[data-val='"+value+"']");
				// 		codeArray.push($li.attr("data-code"));  //data会进行类型转换
				// 		// $ul = $li.children("ul").eq(0);
				// 		$("#weixinChangePage4Wangshang input[name='contactLine']").val($li.attr("data-code"));	//联行号
				// 	});
				// 	$this.parent().find("input[type='hidden']").val(valueText);
				// 	listen4Submit();
				// }
			});
		}
	}

	//校验返回
	function confirm4Back(){

		var accountType = $("#weixinChangePage4Wangshang div[name='accountType'] input[type='hidden']").val();	//账户类型
		var bankDistrict = $("#weixinChangePage4Wangshang div[name='bankDistrict'] input[type='hidden']").val();	//开户行地区
		var mainBank = $("#weixinChangePage4Wangshang div[name='mainBank'] input[type='hidden']").val();	//开户银行
		var branchBank = $("#weixinChangePage4Wangshang div[name='branchBank']>input[type='hidden']").val();	//支行名称
		if(branchBank){
			branchBank = branchBank.trim();
		}
		var accountCode = $("#weixinChangePage4Wangshang input[name='accountCode']").val().trim();	//银行帐号
		var accountName = $("#weixinChangePage4Wangshang input[name='accountName']").val().trim();	//开户名

		//没有修改任何表单
		if(
			accountType == pageVariables.weixinAccount.accountType 
			&& bankDistrict == (pageVariables.weixinAccount.branchProvince + "," + pageVariables.weixinAccount.branchCity)
			&& (mainBank == pageVariables.weixinAccount.bankCode) 
			&& (branchBank == pageVariables.weixinAccount.branchName) 
			&& (accountCode == pageVariables.weixinAccount.bankCardNo) 
			&& (accountName == pageVariables.weixinAccount.bankCertName) 
		){
			if(accountType == Constants.weixin_wangshang.ACCOUNT_TYPE.person){//对私账户

				var accounterCard = $("#weixinChangePage4Wangshang input[name='accounterCard']").val();	//开户人身份证号
				var accounterAddress = $("#weixinChangePage4Wangshang input[name='accounterAddress']").val();	//开户人地址
				if(accounterCard == pageVariables.weixinAccount.certNo && accounterAddress == pageVariables.weixinAccount.cardHolderAddress){
					$.router.back();
					return;
				}

			}else if(accountType == Constants.weixin_wangshang.ACCOUNT_TYPE.company){//对公账户
				var contactLine = $("#weixinChangePage4Wangshang input[name='contactLine']").val().trim();	//联行号
				if(contactLine == pageVariables.weixinAccount.contactLine){
					$.router.back();
					return;
				}
			}
		}

		//已修改：需要确认是否放弃
		DialogUtil.dialogConfirm({
			"title" : "",
			"content" : "离开页面将不会保存本次修改，确定要离开吗？",
			"btnLeft" : "取消",
			"btnRight" : "确定",
			"callbackLeft" : function(){},
			"callbackRight" : function(){
				$.router.back();
			}
		});

		
	}

	//提交：输入监听
	function listen4Submit(){
		var accountType = $("#weixinChangePage4Wangshang div[name='accountType'] input[type='hidden']").val();	//账户类型
		var bankDistrict = $("#weixinChangePage4Wangshang div[name='bankDistrict'] input[type='hidden']").val();	//开户行地区
		var mainBank = $("#weixinChangePage4Wangshang div[name='mainBank'] input[type='hidden']").val();	//开户银行
		var branchBank = $("#weixinChangePage4Wangshang div[name='branchBank']>input[type='hidden']").val();	//支行名称
		if(branchBank){
			branchBank = branchBank.trim();
		}
		var accountCode = $("#weixinChangePage4Wangshang input[name='accountCode']").val().trim();	//银行帐号
		var accountName = $("#weixinChangePage4Wangshang input[name='accountName']").val().trim();	//开户名

		if(accountType && bankDistrict && mainBank && branchBank && accountCode && accountName){
			if(accountType == Constants.weixin_wangshang.ACCOUNT_TYPE.person){//对私账户
				var accounterCard = $("#weixinChangePage4Wangshang input[name='accounterCard']").val();	//开户人身份证号
				var accounterAddress = $("#weixinChangePage4Wangshang input[name='accounterAddress']").val();	//开户人地址
				if(accounterCard && accounterAddress){
					$("#weixinChangePage4Wangshang .header li.right").removeClass("disabled");
				}else{
					$("#weixinChangePage4Wangshang .header li.right").addClass("disabled");
				}
			}else if(accountType == Constants.weixin_wangshang.ACCOUNT_TYPE.company){//对公账户
				var contactLine = $("#weixinChangePage4Wangshang input[name='contactLine']").val().trim();	//联行号
				if(contactLine){
					$("#weixinChangePage4Wangshang .header li.right").removeClass("disabled");
				}else{
					$("#weixinChangePage4Wangshang .header li.right").addClass("disabled");
				}
				
			}
		}else{
			$("#weixinChangePage4Wangshang .header li.right").addClass("disabled");
		}
	}

	//页面事件绑定
	function bindEvent4Page(){

		//监听输入，控制下一步是否可点击
		var listenFormStr = "#weixinChangePage4Wangshang input[name='branchBank']," + 
							"#weixinChangePage4Wangshang input[name='contactLine']," + 
							"#weixinChangePage4Wangshang input[name='accountCode']," + 
							"#weixinChangePage4Wangshang input[name='accountName']," + 
							"#weixinChangePage4Wangshang input[name='accounterCard']," + 
							"#weixinChangePage4Wangshang input[name='accounterAddress']";
		$(document).on("input",listenFormStr,function(e){
			listen4Submit();
		});
		$(document).on("clearInput","#weixinChangePage4Wangshang .zhk-list_gb",function(e){
			listen4Submit();
		});

		//返回
		$(document).on("click","#weixinChangePage4Wangshang .header a.back",function(e){
			confirm4Back();
		});

		//提交
		$(document).on("click","#weixinChangePage4Wangshang .header a[name='submit']",function(e){
			if($(this).parents(".right").hasClass("disabled"))	return;

			submitWeixinChange();
		});
		
	}

	//提交
	function submitWeixinChange(){

		//表单参数
		var accountType = $("#weixinChangePage4Wangshang div[name='accountType'] input[type='hidden']").val();	//账户类型
		var bankDistrict = $("#weixinChangePage4Wangshang div[name='bankDistrict'] input[type='hidden']").val();	//开户行地区
		var bankDistrictText = $("#weixinChangePage4Wangshang div[name='bankDistrict']>ul").mobiscroll("getArrayVal");
		var mainBank = $("#weixinChangePage4Wangshang div[name='mainBank']>input[type='text']").val();	//开户银行名称
		var mainBankId = $("#weixinChangePage4Wangshang div[name='mainBank'] input[type='hidden']").val();// 开户银行ID
		// var branchBank = $("#weixinChangePage4Wangshang input[name='branchBank']").val().trim();	//支行名称
		var branchBank = $("#weixinChangePage4Wangshang div[name='branchBank']>input[type='text']").val().trim();//支行名称
		var contactLine = "";	//联行号
		var accountCode = $("#weixinChangePage4Wangshang input[name='accountCode']").val().trim();	//银行帐号
		var accountName = $("#weixinChangePage4Wangshang input[name='accountName']").val().trim();	//开户名
		var accounterCard = "";	//开户人身份证号
		var accounterAddress = "";	//开户人地址

		//校验：账户类型
		if(!accountType){
			DialogUtil.dialogWarn("请选择账户类型");
			return;
		}

		//校验：开户行地区
		if(!bankDistrict){
			DialogUtil.dialogWarn("请选择开户行地区");
			return;
		}

		//校验：开户银行
		if(!mainBank){
			DialogUtil.dialogWarn("请选择开户银行");
			return;
		}

		//校验：支行名称
		if(!branchBank){
			DialogUtil.dialogWarn("请选择支行名称");
			return;
		}
		if(!/^[\dA-Za-z\u4e00-\u9fa5]+$/.test(branchBank)){
			DialogUtil.dialogWarn("支行名称仅允许输入中文、英文、数字");
			return;
		}
		if(branchBank.length > 64){
			DialogUtil.dialogWarn("支行名称长度不能超过64");
			return;
		}

		//校验：联行号
		// if(accountType == Constants.weixin_wangshang.ACCOUNT_TYPE.company){//对公账户
		contactLine = $("#weixinChangePage4Wangshang input[name='contactLine']").val().trim();	//联行号

		if(contactLine.length == 0){
			DialogUtil.dialogWarn("请填写联行号");
			return;
		}
		if(!/^\d{1,20}$/.test(contactLine)){
			DialogUtil.dialogWarn("请填写有效的联行号");
			return;
		}
		// }
		
		//校验：银行帐号
		if(accountCode.length == 0){
			DialogUtil.dialogWarn("请填写银行账号");
			return;
		}
		if(!/^\d{1,32}$/.test(accountCode)){
			DialogUtil.dialogWarn("请填写有效的银行账号");
			return;
		}

		//校验：开户名
		if(!accountName){
			DialogUtil.dialogWarn("请填写开户人名称");
			return;
		}
		if(!/^[\dA-Za-z\u4e00-\u9fa5]+$/.test(accountName)){
			DialogUtil.dialogWarn("开户人名称仅允许输入中文、英文、数字");
			return;
		}
		if(accountName.length > 64){
			DialogUtil.dialogWarn("开户人名称长度不能超过64");
			return;
		}
		if(accountType == Constants.weixin_wangshang.ACCOUNT_TYPE.person){//对私账户
			if(accountName != pageVariables.weixinAccount.principal){
				DialogUtil.dialogWarn("开户名需与负责人名称一致");
				return;
			}
		}
		if(accountType == Constants.weixin_wangshang.ACCOUNT_TYPE.company){//对公账户
			if(accountName != pageVariables.weixinAccount.merchantName){
				DialogUtil.dialogWarn("开户名需与门店名称一致");
				return;
			}
		}

		if(accountType == Constants.weixin_wangshang.ACCOUNT_TYPE.person){//对私账户

			accounterCard = $("#weixinChangePage4Wangshang input[name='accounterCard']").val().trim();	//开户人身份证号
			accounterAddress = $("#weixinChangePage4Wangshang input[name='accounterAddress']").val().trim();	//开户人地址

			//开户人身份证号
			if(accounterCard.length == 0){
				DialogUtil.dialogWarn("请填写开户人身份证号码");
				return;
			}
			if(!/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(accounterCard)){
				DialogUtil.dialogWarn("请填写有效的开户人身份证号码");
				return;
			}
			if(accounterCard != pageVariables.weixinAccount.idCard){
				DialogUtil.dialogWarn("开户人身份证号必须与负责人身份证号一致");
				return;
			}

			//校验：开户人地址
			if(!accounterAddress){
				DialogUtil.dialogWarn("请填写开户人地址");
				return;
			}
			if(!/^[\dA-Za-z\u4e00-\u9fa5]+$/.test(accounterAddress)){
				DialogUtil.dialogWarn("开户人地址仅允许输入中文、英文、数字");
				return;
			}
			if(accounterAddress.length > 128){
				DialogUtil.dialogWarn("开户人地址长度不能超过128");
				return;
			}
			
		}

		//提交
		var stepTwo = {
			"merchantId" : pageVariables.weixinAccount.merchantId,
			"accountType" : accountType,	//账户类型
			"branchProvince" : bankDistrict.split(",")[0],	//开户行省份
			"branchProvinceName" : bankDistrictText[0],
			"branchCity" : bankDistrict.split(",")[1],	//开户行市
			"branchCityName" : bankDistrictText[1],
			"bankCode" : mainBank,	//开户银行
			"bankId":mainBankId,//开户银行ID
			"branchName" : branchBank,	//支行名称
			"bankCardNo" : accountCode,	//银行帐号
			"bankCertName" : accountName,	//开户名
			"contactLine":contactLine,//银联号
		};
		if(accountType == Constants.weixin_wangshang.ACCOUNT_TYPE.person){//对私账户
			stepTwo["certNo"] = accounterCard;
			stepTwo["cardHolderAddress"] = accounterAddress;
		}else if(accountType == Constants.weixin_wangshang.ACCOUNT_TYPE.company){//对公账户
			// stepTwo["contactLine"] = contactLine;
		}

		common.loading("提交中");
		AppUtil.call(
		// apiTest.testSubmit(
			AppUtil.APIS.SEND_HTTP_REQUEST,
			{
				"type":"POST",
				"url":App.serverUrl + "/app/wxAccountCloudBox/change.do",
				"data" : JSON.stringify(stepTwo)
			},
			function(result){
				common.closeLoading();
				
				var cache = CommonUtil.takeOutParamObject() || {};
				cache.shopId = pageVariables.shopId;
				CommonUtil.injectParamObject(cache);

				if(result.success.toString() == "true" && result.resultObject.success.toString() == "true"){//success
					$.router.load("weixin_change_success_wangshang.html");
				}else{
					var errorMsg = "";
					if(result.success.toString() == "false"){//app error
						errorMsg = result.msg;
					}else if(result.resultObject.success.toString() == "false"){//server error
						errorMsg = result.resultObject.msg;
					}
					
					var cache = CommonUtil.takeOutParamObject() || {};
					cache.errorMsg = errorMsg;
					CommonUtil.injectParamObject(cache);
					$.router.load("weixin_change_error_wangshang.html");
				}
			}
		);
	}

	/**
	 * 测试接口
	 * @type {Object}
	 */
	var apiTest = {

		"testStoreDetail" : function(options){
			options.success({
				"success" : true,
				"resultObject" : {
					"shopId" : "1",
					"mainShopName" : "麦当劳",
					"branchShopName" : "上地南路店",
					"categoryLevel1" : "美食",
					"categoryLevel2" : "西餐",
					"categoryLevel3" : "快餐",
					"contactNumber" : "11111111111",
					"address" : "北京市海淀区上地南路88号",
					"isOnline" : "T", //口碑门店状态 T ：上架 F：下架
					"serviceVersionType" : "1",	//订购版本 0：未订购 1：金元宝 2：银元宝 3：快享付
					"proUpgradeStatus" : "1", //订购状态 0：未订购 1：正常 2：已退订 3：已过期
					"expireDate" : "2017-05-08 12:12:12",	
					"alipayPayStatus" : "1", //支付宝开通状态 0：未开通 1：已开通
					"merchantStatus" : "1", //微信开通状态 0：未开通 1：已开通 2：已冻结
					"merchantId" : "001", //微信支付商户号
				}
				
			});
		},

		"testGetAccount" : function(options){//查询微信账户
			options.success({
				"success" : true,
				"resultObject" : {
					"accountType" : "1" , //1:企业 ;2:个人
					"province" : "170000",
					"provinceName" : "湖北省",
					"city" : "170100",
					"cityName" : "武汉市",
					"bankId" : "002",
					"bankMainName" : "中国工商银行",
					"bankName" : "上地支行",
					"contactLine" : "111111111112",
					"accountCode" : "6228480000000000000",
					"accountName" : "张三", //开户人姓名/收款单位
					"idCard" : "42128119999999999X",//身份证
					"accounterAddress" : "上地南路"
				}
			});
		},

		"testGetBankList" : function(options){//获取开户银行列表
			options.success({
				"success" : true,
				"resultObject" : [
					{"bankCode" : "001" , "bankName" : "中国银行"},
					{"bankCode" : "002" , "bankName" : "中国工商银行"},
					{"bankCode" : "003" , "bankName" : "中国建设银行"},
					{"bankCode" : "004" , "bankName" : "中国农业银行"}
				]
			});
		},

		"testSubmit" : function(apiName,params,callback){//提交变更
			callback({
				"code" : "0",
				"msg" : "",
				"resultObject" : {
					"code" : "0",
					"msg" : "参数不正确",
					"success" : false,
					"resultObject" : ""
				},
				"success" : true
			});
		}
	};

})(document, window);